<?php
/**
 * Created by PhpStorm.
 * User: perevozkin
 * Date: 18.03.14
 * Time: 10:44
 */

function xmldb_mymodule_upgrade($oldversion) {
    global $CFG;

    $result = TRUE;

// Insert PHP code from XMLDB Editor here
    if ($oldversion < XXXXXXXXXX) {

        // Define table block_book to be created.
        $table = new xmldb_table('block_book');

        // Adding fields to table block_book.
        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);

        // Adding keys to table block_book.
        $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));

        // Conditionally launch create table for block_book.
        if (!$dbman->table_exists($table)) {
            $dbman->create_table($table);
        }

        // Book savepoint reached.
        upgrade_block_savepoint(true, XXXXXXXXXX, 'book');
    }


    return $result;
}